www.gusucode.com > 地平线cms ASP.NET门户网站系统 v2.x源码程序 > 地平线cms ASP.NET门户网站系统 v2.x/deepsooncmsV2.2/deepsooncmsV2.2/Admin/Editor/EditotFunctions.js

    var itemFontsizeValue=['8','10','12','14','18','24','32'];
var itemFontSize=['特小','极小','小','普通','大','极大','特大'];
var itemColors=['#ffffff','#000000','#eeece1','#1f497d','#4f81bd','#c0504d','#9bbb59','#8064a2','#4bacc6','#f79646',
'#f2f2f2','#7f7f7f','#ddd9c3','#c6d9f0','#dbe5f1','#f2dcdb','#ebf1dd','#e5e0ec','#dbeef3','#fdeada',
'#d8d8d8','#595959','#c4bd97','#8db3e2','#b8cce4','#e5b9b7','#d7e3bc','#ccc1d9','#b7dde8','#fbd5b5',
'#bfbfbf','#3f3f3f','#938953','#548dd4','#95b3d7','#d99694','#c3d69b','#b2a2c7','#92cddc','#fac08f',
'#a5a5a5','#262626','#494429','#17365d','#366092','#953734','#76923c','#5f497a','#31859b','#e36c09',
'#7f7f7f','#0c0c0c','#1d1b10','#0f243e','#244061','#632423','#4f6128','#3f3151','#205867','#974806',
'#c00000','#ff0000','#ffc000','#ffff00','#92d050','#00b050','#00b0f0','#0070c0','#002060','#7030a0'];
var itemFontFamily=['宋体','仿宋体','黑体','隶书','楷体','微软雅黑','Arial','Arial Narrow','Arial Black','Times New Roman','Verdana'];
var itemJustify=['左对齐','居中','右对齐','两端对齐'];
var itemJustifyValue=['Justifyleft','Justifycenter','Justifyright','Justifyfull'];
var nowPanelID="fontFamily";
var defaultValue="http://";
var fullScreenStat=false;
var htmlStat=false;
var range,sel,bookmark,SelTxt="",SelTxtLink="";
//判断浏览器版本
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

function deactivateEve(){
	sel=document.selection ? document.selection : window.getSelection();;
	range = sel.createRange ? sel.createRange() : sel.rangeCount > 0?sel.getRangeAt(0):null;
	bookmark= range.getBookmark();
	
	SelTxt=range.text;
	if(SelTxt!="")
	document.getElementById("linkTextSpan").style.display="none";
	else document.getElementById("linkTextSpan").style.display="block";
	
	parentElement = range.parentElement();
	if(parentElement.tagName=="A"){
	SelTxtLink = range.parentElement().attributes("href").value;
	document.getElementById("linkHref").value= SelTxtLink;
	}
	else document.getElementById("linkHref").value="http://";
}

function activeEve(){
	if(bookmark){  
		range.moveToBookmark(bookmark);  
		range.select();  
		bookmark = null;  
	}
}

function drawFontSizeMenu(){
	for(num=0;num<7;num++)
		document.write("<span class='fontSizeSpan' style='padding:5px;;font-size:"+itemFontsizeValue[num]+"px;line-height:"+itemFontsizeValue[num]+"px;' onClick='setFontSize("+num+")' onMouseOver='ItemFocus(this);'onMouseOut='ItemNormal(this);'>"+itemFontSize[num]+"("+itemFontsizeValue[num]+"px)</span>");
}

function drawFontFamilyMenu(){
	for(num=0;num<11;num++)
		document.write("<span class='fontFamilySpan' style='font-Family:"+itemFontFamily[num]+";' onMouseDown='setFontFamily("+num+")' onMouseOver='ItemFocus(this);'onMouseOut='ItemNormal(this);'>"+itemFontFamily[num]+"</span>");
}

function drawJustifyMenu(){
	for(num=0;num<4;num++)
		document.write("<span class='JustifySpan' onMouseDown='setJustify("+num+")' onMouseOver='ItemFocus(this);'onMouseOut='ItemNormal(this);'>"+itemJustify[num]+"</span><br>");
}

function drawOrderedListMenu(){
	document.write("<span class='JustifySpan' onMouseDown='insertOrderedList(0)' onMouseOver='ItemFocus(this);'onMouseOut='ItemNormal(this);'>数字列表</span><br>");
	document.write("<span class='JustifySpan' onMouseDown='insertOrderedList(1)' onMouseOver='ItemFocus(this);'onMouseOut='ItemNormal(this);'>符号列表</span><br>");
}

function changeLinkStyleValue(obj){
	document.getElementById("linkStyleValue").value=obj.options[obj.selectedIndex].getAttribute('value');
}

function drawCreatelinkMenu(){
	document.write("<div class='linkBox'>");
	document.write("链接地址: <input name='linkHref' id='linkHref' type='text' class='inputStyle' value='http://'><br>");
	document.write("<span id='linkTextSpan' style='display:block;'>链接文字: <input name='linkText' id='linkText' type='text' class='inputStyle'><br></span>");
	document.write("<input type=hidden name='linkStyleValue'id='linkStyleValue' value='_blank'>");
	document.write("链接方式: <select name='linkStyle' size=1 style='background:#FFFFFF;margin-bottom:3px;'onchange='changeLinkStyleValue(this)'");
	document.write("<option>请选择<option value='_blank' selected>_blank<option value='_self'>_self</select><br>");
	document.write("<input value='确认' onClick='creatLink()' type='button' class='buttonStyle'> <input value='取消' onMouseDown='closeMenu()' type='button' name='upfile' class='buttonStyle'></div>");
}

function drawInsertFlvMenu(){
	document.write("<div class='linkBox'>");
	document.write("视频地址: <input name='flvHref' id='flvHref' type='text' class='inputStyle' value='http://'><br>");
	document.write("视频简介: <input name='flvText' id='flvText' type='text' class='inputStyle'><br>");
	document.write("<input value='插入视频' onClick='creatFlv()' type='button' class='buttonStyle'> <input value='取消' onMouseDown='closeMenu()' type='button' name='upfile' class='buttonStyle'></div>");
}

function changeAlignStyleValue(obj){
	document.getElementById("alignStyleValue").value=obj.options[obj.selectedIndex].getAttribute('value');
}

function drawInsertImgMenu(){
	document.write("<div class='linkBox'>");
	document.write("图片地址: <input name='imgHref' id='imgHref' type='text' class='inputStyle' value='http://'> 必填<br>");
	document.write("<input type=hidden name='alignStyleValue'id='alignStyleValue' value=''>");
	document.write("对齐方式: <select name='alignStyle' size=1 style='background:#FFFFFF;margin-bottom:3px;'onchange='changeAlignStyleValue(this)'");
	document.write("<option>请选择<option value='' selected>默认方式<option value='left'>居左对齐<option value='right'>居右对齐</select><br>");
	document.write("<input value='插入图片' onClick='creatImg()' type='button' class='buttonStyle'> <input value='取消' onMouseDown='closeMenu()' type='button' name='upfile' class='buttonStyle'></div>");
}

function drawInsertFileMenu(){
	document.write("<div class='linkBox'>");
	document.write("文件地址: <input name='fileHref' id='fileHref' type='text' class='inputStyle' value='http://'> 必填<br>");
	document.write("文件名称: <input name='fileName' id='fileName' type='text' class='inputStyle'> 必填<br>");
	document.write("<input value='插入文件' onClick='creatFile()' type='button' class='buttonStyle'> <input value='取消' onMouseDown='closeMenu()' type='button' name='upfile' class='buttonStyle'></div>");
}

function drawInsertTableMenu(){
	document.write("<div class='linkBox'>");
	document.write("行数列数:<input type='text' id='tableForRows' name='tableForRows' class='inputStyle' style='width:40px;' value='3'> ");
	document.write(" &times; <input type='text' id='tableForCols' name='tableForCols' class='inputStyle'style='width:40px;'value='4'><br>");
	document.write("宽度高度:<input type='text' id='tableForWidth' name='tableForWidth' class='inputStyle'style='width:40px;'value='160'> ");
	document.write(" &times; <input type='text' id='tableForHeight' name='tableForHeight' class='inputStyle'style='width:40px;'value='40'><br>");
	document.write("表格标题:<input type='text' id='tableForTitle' name='tableForTitle' class='inputStyle'style='width:104px;' value='请填写表格标题'><br>");
	document.write("<input value='插入表格' onClick='insertTable()' type='button' class='buttonStyle'> <input value='取消' onMouseDown='closeMenu()' type='button' name='upfile' class='buttonStyle'></div>");
}

function drawAboutMenu(){
	document.write("<div class='linkBox'>红豆编辑器 <FONT face='Times New Roman'>&copy;</font> 版权所有<br>书红开发设计");
}

function ItemFocus(Obj){
	Obj.style.background='#ABABA8';
	Obj.style.color='#FFFFFF';
}

function ItemNormal(Obj){
	Obj.style.background='#FFFFFF';
	Obj.style.color='#000000';
}

function colorItemFocus(Obj){
	Obj.style.border='1px solid #000000';
}

function colorItemNormal(Obj,ColorIndex){
	Obj.style.border='1px solid '+itemColors[ColorIndex];
}

function drawColorMenu(){
	document.write("<span style='font-size:12px;color:#888888;'>主题颜色:</span><br>");
	for(col=0;col<10;col++)
		document.write("<span class='colorSpan' style='background:"+itemColors[col]+";margin-right:2px;margin-bottom:2px;border:1px solid "+itemColors[col]+";' onMouseDown='setSelForeColor("+(col)+")' onMouseOver='colorItemFocus(this)' onMouseOut='colorItemNormal(this,"+col+")'>&nbsp;&nbsp;</span>");
	document.write("<br>");
	for(row=1;row<5;row++){
		for(col=0;col<10;col++)
			document.write("<span class='colorSpan' style='background:"+itemColors[10*row+col]+";border:1px solid "+itemColors[10*row+col]+";margin-right:2px;' onMouseDown='setSelForeColor("+(10*row+col)+")' onMouseOver='colorItemFocus(this)' onMouseOut='colorItemNormal(this,"+(10*row+col)+")'>&nbsp;&nbsp;</span>");
		document.write("<br>");
	}
	document.write("<span style='font-size:12px;color:#888888;margin-top:2px;'>标准颜色:</span><br>");
	for(col=60;col<70;col++)
		document.write("<span class='colorSpan' style='background:"+itemColors[col]+";margin-right:2px;margin-bottom:2px;border:1px solid "+itemColors[col]+";' onMouseDown='setSelForeColor("+(col)+")' onMouseOver='colorItemFocus(this)' onMouseOut='colorItemNormal(this,"+col+")'>&nbsp;&nbsp;</span>");
}

function drawBackColorMenu(){
	document.write("<span style='font-size:12px;color:#888888;'>主题颜色:</span><br>");
	for(col=0;col<10;col++)
		document.write("<span class='colorSpan' style='background:"+itemColors[col]+";margin-right:2px;margin-bottom:2px;border:1px solid "+itemColors[col]+";' onMouseDown='setBackColor("+(col)+")' onMouseOver='colorItemFocus(this)' onMouseOut='colorItemNormal(this,"+col+")'>&nbsp;&nbsp;</span>");
	document.write("<br>");
	for(row=1;row<5;row++){
		for(col=0;col<10;col++)
			document.write("<span class='colorSpan' style='background:"+itemColors[10*row+col]+";border:1px solid "+itemColors[10*row+col]+";margin-right:2px;' onMouseDown='setBackColor("+(10*row+col)+")' onMouseOver='colorItemFocus(this)' onMouseOut='colorItemNormal(this,"+(10*row+col)+")'>&nbsp;&nbsp;</span>");
		document.write("<br>");
	}
	document.write("<span style='font-size:12px;color:#888888;magin-top:2px;'>标准颜色:</span><br>");
	for(col=60;col<70;col++)
		document.write("<span class='colorSpan' style='background:"+itemColors[col]+";margin-right:2px;margin-bottom:2px;border:1px solid "+itemColors[col]+";' onMouseDown='setBackColor("+(col)+")' onMouseOver='colorItemFocus(this)' onMouseOut='colorItemNormal(this,"+col+")'>&nbsp;&nbsp;</span>");
}

function setSelForeColor(colorIndex){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		var rangeTemp = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		rangeTemp.execCommand("ForeColor","true",itemColors[colorIndex]);
	}
	else{//非IE浏览器
		var selectTxt = document.getElementById('contentBox').contentWindow.document.getSelection();
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","","<font color="+itemColors[colorIndex]+">"+selectTxt+"</font>"); 
	}
	hiddenMenu(nowPanelID);
}

function setBackColor(colorIndex){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		var rangeTemp = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		rangeTemp.execCommand("BackColor","true",itemColors[colorIndex]);
	}
	else{//非IE浏览器
		var selectTxt = document.getElementById('contentBox').contentWindow.document.getSelection();
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","","<span style=background-color:"+itemColors[colorIndex]+">"+selectTxt+"</span>"); 
	}
	hiddenMenu(nowPanelID);
}

function BarFocus(BarID){
	if(BarID != nowPanelID)
		hiddenMenu(nowPanelID);
}


function showMenu(PanelID){
	if(PanelID != nowPanelID)hiddenMenu(nowPanelID);
	nowPanelID=PanelID;
	document.getElementById(PanelID+"Menu").style.display="inline";
	showCoverDiv();
	document.getElementById(PanelID+"Menu").style.zIndex=1001;
}


function showCoverDiv() //根据屏幕的大小显示两个层
{
  //var range = getRange();
  //document.getElementById("CoverDiv").style.width = range.width + "px";
  //document.getElementById("CoverDiv").style.height = range.height + "px";
  document.getElementById("CoverDiv").style.display = "block";
}
function getRange() //得到屏幕的大小
{
  var top = document.body.scrollTop;
  var left = document.body.scrollLeft;
  var clientheight = document.body.clientHeight;
  var scrollheight = document.body.scrollHeight;
  var height = clientheight>scrollheight?clientheight:scrollheight;
  var width = document.body.clientWidth;
  if (top==0 && left==0 && height==0 && width==0){
     top = document.documentElement.scrollTop;
     left = document.documentElement.scrollLeft;
     height = document.documentElement.clientHeight;
     width = document.documentElement.clientWidth;
  }
  return {top:top ,left:left ,height:height ,width:width } ;
}


function hiddenMenu(PanelID){
	document.getElementById(PanelID+"Menu").style.display="none";
	document.getElementById("CoverDiv").style.display = "none";
}

function closeMenu(){
	hiddenMenu(nowPanelID);
}

function setBold(){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		var rangeTemp = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		rangeTemp.execCommand("Bold", false, null);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("Bold", false, null);
	}
}


function setItalic(){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		var rangeTemp = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		rangeTemp.execCommand("Italic", false, null);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("Italic", false, null); 
	}
}

function setUnderline(){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		var rangeTemp = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		rangeTemp.execCommand("Underline", false, null);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("Underline", false, null);
	}
}

function setStrikethrough(){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		var rangeTemp = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		rangeTemp.execCommand("Strikethrough", false, null);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("Strikethrough", false, null);
	}
}

function setFontSize(FontSizeValue){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		FontFamilyStr="<span style='font-size:"+itemFontsizeValue[FontSizeValue]+"px;'>"+(document.selection.createRange().text)+"</span>";
		var rangeTemp = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		rangeTemp.pasteHTML(FontFamilyStr);
	}
	else{//非IE浏览器
		FontFamilyStr="<span style='font-size:"+itemFontsizeValue[FontSizeValue]+"px;'>"+(window.getSelection().toString())+"</span>";
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",FontFamilyStr); 
	}
	hiddenMenu(nowPanelID);
}

function setFontFamily(FontFamilyIndex){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		FontFamilyStr="<span style='font-Family:"+itemFontFamily[FontFamilyIndex]+";'>"+(document.selection.createRange().text)+"</span>";
		var rangeTemp = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		rangeTemp.pasteHTML(FontFamilyStr);
	}
	else{//非IE浏览器
		FontFamilyStr="<span style='font-Family:"+itemFontFamily[FontFamilyIndex]+";'>"+(window.getSelection().toString())+"</span>";
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",FontFamilyStr); 
	}
	hiddenMenu(nowPanelID);
}

function setJustify(index){
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		var range = document.getElementById('contentBox').contentWindow.document.selection.createRange();
		range.execCommand(itemJustifyValue[index], false, null);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand(itemJustifyValue[index], false, null); 
	}
	hiddenMenu(nowPanelID);
}

function insertOrderedList(style){
	document.getElementById("contentBox").focus();
	if(style==0){
		if (Sys.ie){//如果是IE浏览器
			var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
			range.execCommand("InsertOrderedList", false, null);
		}
		else{//非IE浏览器
			document.getElementById('contentBox').contentWindow.document.execCommand("InsertOrderedList", false, null); 
		}
	}
	else {
		if (Sys.ie){//如果是IE浏览器
			var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
			range.execCommand("InsertUnorderedList", false, null);
		}
		else{//非IE浏览器
			document.getElementById('contentBox').contentWindow.document.execCommand("InsertUnorderedList", false, null);  
		}
	}
	hiddenMenu(nowPanelID);
}

function creatLink(){
	linkHref=document.getElementById("linkHref").value;
	linkText=document.getElementById("linkText").value;
	if(SelTxt!="")linkText=SelTxt;
	linkStyleValue=document.getElementById("linkStyleValue").value;
	linkStr="<a href='"+linkHref+"' target='"+linkStyleValue+"'>"+linkText+"</a>";
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		range.pasteHTML(linkStr);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",linkStr );
	}
	document.getElementById("linkHref").value="http://";
	document.getElementById("linkText").value="";
	hiddenMenu(nowPanelID);
}

function insertImgs(){
	imgsStr="";
	imgsStr += "<span class='Album' id='Album'>";
	imgsStr += "<ul class='ImgList4Album' id='ImgList4Album'>";
		imgsStr += "<li>插入图片处,添加多幅图片请按Enter键(请手动将本行文字提示删除,注意保留左边的列表标志黑圆点)</li>";
	imgsStr += "</ul>";
	imgsStr += "<span class='hiddenInforSpan'>--------请在上面提示处插入图片,添加多幅图片请按Enter键-------<br></span>";
	imgsStr += "<span class='imgInfor4Album'>第<span id='currentImg4Album'>1</span>幅/共<span id='sumImg4Album'>1</span>幅</span>";
	imgsStr += "<center><img src='images/DefaultImg4Album.png' id='showCurrentImg'>";
	imgsStr += "<ul class='AlbumButton' id='AlbumButton'>";
		imgsStr += "<li>&lt;</li>";
		imgsStr += "<li>&gt;</li>";
	imgsStr += "</ul></center>";
	imgsStr += "</span><br><br>";
	imgsStr += "<script src='Resources/Js/viewAlbum.js' type='text/javascript'></script>";
	if (Sys.ie){//如果是IE浏览器
		var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		range.pasteHTML(imgsStr);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",imgsStr ); 
	}
}


function unLink(){
	if (Sys.ie){//如果是IE浏览器
		var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		range.execCommand("Unlink");
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("Unlink"); 
	} 
	hiddenMenu(nowPanelID);
}

function creatFlv(){
	var flvHref=document.getElementById("flvHref").value;
	var flvText=document.getElementById("flvText").value;
	var flvStr = flvText + "<br><object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=400 height=300 id=Player>"
		flvStr = flvStr + "<param name=movie value=/resources/flash/player.swf />"
		flvStr = flvStr + "<param name=quality value=high />"
		flvStr = flvStr + "<param name=allowFullScreen value=true />"
		flvStr = flvStr + "<param name=FlashVars value=file="+flvHref+"&autostart=true&volume=60&backcolor=&0x000000&frontcolor=0xCCCCCC&lightcolor=0x557722 />"
		flvStr = flvStr + "<embed src=/resources/flash/player.swf allowfullscreen=true  width=400 height=300  flashvars=file="+flvHref+"&autostart=true&volume=60&backcolor=&0x000000&frontcolor=0xCCCCCC&lightcolor=0x557722 quality=high  type=application/x-shockwave-flash ></embed>"
		flvStr = flvStr + "</object>"
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		range.pasteHTML(flvStr);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",flvStr );
	}
	hiddenMenu(nowPanelID);
}

function creatImg(){
	imgHref=document.getElementById('imgHref').value;
	alignStyle=document.getElementById('alignStyleValue').value;
	imgStr="<img src='"+imgHref+"' align='"+alignStyle+"'>";
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		range.pasteHTML(imgStr);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",imgStr );
	} 
	hiddenMenu(nowPanelID);
}

function creatFile(){
	fileHref=document.getElementById('fileHref').value;
	fileName=document.getElementById('fileName').value;
	fileStr="<a href='"+fileHref+"' target='_blank'>"+fileName+"</a>";
	document.getElementById("contentBox").focus();
	if (Sys.ie){//如果是IE浏览器
		range.pasteHTML(fileStr);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",fileStr );
	}
	hiddenMenu(nowPanelID);
}

function Removeformat(){
	if (Sys.ie){//如果是IE浏览器
		var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		range.execCommand("Removeformat");
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("Removeformat"); 
	}
}

function SelectAll(){
	if (Sys.ie){//如果是IE浏览器
		var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		range.execCommand("SelectAll");
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("SelectAll"); 
	}
}

function insertTable(){
	tableRows=document.getElementById("tableForRows").value>2?document.getElementById("tableForRows").value:2;
	tableCols=document.getElementById("tableForCols").value>2?document.getElementById("tableForCols").value:2;
	tableWidth=document.getElementById("tableForWidth").value>160?document.getElementById("tableForWidth").value:160;
	tableHeight=document.getElementById("tableForHeight").value>40?document.getElementById("tableForHeight").value:40;
	tableTitle=document.getElementById("tableForTitle").value;
	tableStr="<table cellspacing=0 cellpadding=0 style='font-size:13px;border-left:1px solid #AFAFA9;border-top:1px solid #AFAFA9;width:"+tableWidth+"px;height:"+tableHeight+"px;'><caption style='text-align:center;'>"+tableTitle+"</caption>";
	for(rows=0;rows<tableRows;rows++){
		tableStr+="<tr>";
		for(cols=0;cols<tableCols;cols++)
			tableStr+="<td style='border-right:1px solid #AFAFA9;border-bottom:1px solid #AFAFA9;padding:2px;'></td>";
		tableStr+="</tr>";
	}
	tableStr+="</table>"
	if (Sys.ie){//如果是IE浏览器
		//var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		range.pasteHTML(tableStr);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",tableStr ); 
	}
	hiddenMenu(nowPanelID);
}

function insertTime(){
	var now=new Date();
	if (Sys.ie){//如果是IE浏览器
		var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
			range.text=range.text+now.toLocaleString( );
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",now.toLocaleString( ) ); 
	}
}

function insertHr(){
	htStr = "<div style='width:620px;font-size:6px;border-top:1px solid #CCCCCC;margin-top:6px;'>";
	if (Sys.ie){//如果是IE浏览器
		var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		range.pasteHTML(htStr);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",htStr ); 
	}
}

function insertFileText(FileStr){
	if (Sys.ie){//如果是IE浏览器
		range.pasteHTML(FileStr);
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","",FileStr ); 
	}
	hiddenMenu(nowPanelID);
}

function setPageTag(){
	if (Sys.ie){//如果是IE浏览器
		var range = document.getElementById('contentBox').contentWindow.document.selection.createRange(); 
		range.pasteHTML("<-分页符->");
	}
	else{//非IE浏览器
		document.getElementById('contentBox').contentWindow.document.execCommand("insertHtml","","<-分页符->" ); 
	}
}

function fullScreen(){
	if(!fullScreenStat){
		fullScreenStat=true;
		document.getElementById("HdEditorLayout").className='FullScreen';
		document.getElementById("toolBar").className='FullScreen';
	}
	else{
		fullScreenStat=false;
		document.getElementById("HdEditorLayout").className='NormalScreen';
	}
}

function html(){
	if(!htmlStat){
		htmlStat=true;
		document.getElementById("contentBox").style.display="none";
		document.getElementById("contentTxt").style.display="block";
		document.getElementById("contentTxt").value=document.getElementById('contentBox').contentWindow.document.body.innerHTML;
	}
	else{
		htmlStat=false;
		document.getElementById("contentBox").style.display="block";
		document.getElementById("contentTxt").style.display="none";
		document.getElementById('contentBox').contentWindow.document.body.innerHTML=document.getElementById("contentTxt").value;
	}
}

function setClipboard(maintext) {
   if (window.clipboardData) {
      return (window.clipboardData.setData("Text", maintext));
   }
   else if (window.netscape) {
      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
      var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
      if (!clip) return;
      var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
      if (!trans) return;
      trans.addDataFlavor('text/unicode');
      var str = new Object();
      var len = new Object();
      var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
      var copytext=maintext;
      str.data=copytext;
      trans.setTransferData("text/unicode",str,copytext.length*2);
      var clipid=Components.interfaces.nsIClipboard;
      if (!clip) return false;
      clip.setData(trans,null,clipid.kGlobalClipboard);
      return true;
   }
   return false;
}


function getClipboard() {
   if (window.clipboardData) {
      return(window.clipboardData.getData('Text'));
   }
   else if (window.netscape) {
      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
      var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
      if (!clip) return;
      var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
      if (!trans) return;
      trans.addDataFlavor('text/unicode');
      clip.getData(trans,clip.kGlobalClipboard);
      var str = new Object();
      var len = new Object();
      try {
         trans.getTransferData('text/unicode',str,len);
      }
      catch(error) {
         return null;
      }
      if (str) {
         if (Components.interfaces.nsISupportsWString) str=str.value.QueryInterface(Components.interfaces.nsISupportsWString);
         else if (Components.interfaces.nsISupportsString) str=str.value.QueryInterface(Components.interfaces.nsISupportsString);
         else str = null;
      }
      if (str) {
         return(str.data.substring(0,len.value / 2));
      }
   }
   return null;
}

// 清除WORD冗余格式并粘贴
function cleanAndPaste( html ) {
	// Remove all SPAN tags
	html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
	// Remove all A tags
	//html = html.replace(/<\/?A[^>]*>/gi, "" );
	// Remove all font tags
	html = html.replace(/<\/?font[^>]*>/gi, "" );
	// Remove all u tags
	html = html.replace(/<\/?u[^>]*>/gi, "" );
	// Remove onmouseover attributes
	html = html.replace(/<(\w[^>]*) onmouseover=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	// Remove onmouseout attributes
	html = html.replace(/<(\w[^>]*) onmouseout=([^ |>]*)([^>]*)/gi, "<$1$3") ;

	// Remove Class attributes
	html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	// Remove Face attributes
	html = html.replace(/<(\w[^>]*) face=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	// Remove Size attributes
	html = html.replace(/<(\w[^>]*) size=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	// Remove X:num attributes
	html = html.replace(/<(\w[^>]*) x:num=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	// Remove Width attributes
	//html = html.replace(/<(\w[^>]*) width=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	// Remove Height attributes
	//html = html.replace(/<(\w[^>]*) height=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	// Remove Class attributes
	html = html.replace(/<(\w[^>]*) class=([^  |>]*)([^>]*)/gi, "<$1$3") ;  
	// Remove Style attributes
	//html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
	// Remove Lang attributes
	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	// Remove XML elements and declarations
	html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
	// Remove Tags with XML namespace declarations: <o:p></o:p>
	html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
	// Replace the &nbsp;
	html = html.replace(/&nbsp;/, " " );

	// Transform <P> to <DIV>
	var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ; // Different because of a IE 5.0 error
	html = html.replace( re, "<p$2</p>" ) ;

	html=html.replace(/ x:num/g,"");

	return html ;
}


function setFormatDataFuction(){
	var editorRange=document.getElementById("contentBox").document.selection.createRange();//获得编辑器鼠标位置

	filterDataObj=document.getElementById("filterDataDiv");//给过滤器存放原始文本数据
	filterDataObj.focus();
	filterDataObj.document.execCommand("Paste",false,null);

	filterData=cleanAndPaste(filterDataDiv.innerHTML);//获取过滤后的清洁数据
	editorRange.pasteHTML(filterData);//在编辑器鼠标位置插入过滤后的数据

	filterDataDiv.innerHTML="";//清空过滤器中的数据
}